<!--
 * @Author: zulezhe
 * @Date: 2022-03-25 16:37:43
 * @LastEditors: zulezhe
 * @LastEditTime: 2022-03-28 14:44:08
 * @Path: https://gitee.com/zulezhe/
 * @Description: 
-->
<template>
  <!-- 添加或修改配置对话框 -->
  <el-dialog :title="title" v-model="open" width="500px" append-to-body>
    <el-form ref="managerRef" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="地址" prop="address">
        <el-input v-model="form.address" placeholder="请输入地址" />
      </el-form-item>
      <el-form-item prop="addressType" label="地址类型">
        <el-select
          v-model="form.addressType"
          placeholder="请选择地址类型"
          clearable
          style="width: 200px"
        >
          <el-option label="离线地址" value="0" />
          <el-option label="在线地址" value="1" />
          <el-option label="睡眠" value="2" />
          <el-option label="下载" value="3" />
        </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="memo">
        <el-input v-model="form.memo" placeholder="请输入备注" />
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
//API接口
import api from "@/api";
//引入消息弹出框
import { ElMessage, ElMessageBox } from "element-plus";

export default {
  components: {},
  data() {
    return {
      //表单验证
      form: {},
      open: false, //表单状态
      title: "", //表单标题
      rules: {
        address: [{ required: true, message: "地址不能为空", trigger: "blur" }],
      },
    };
  },
  methods: {
    /** 提交按钮 */
    submitForm() {
      this.$refs["managerRef"].validate((valid) => {
        if (valid) {
          this.$emit("getData", this.form);
          this.open = false;
        }
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.$refs.managerRef.resetFields();
    },
  },
};
</script>

<style lang="less" scoped>
:deep(.el-tabs__nav-scroll) {
  padding: 0 20px;
}
</style>
